package qiniu.voidcepc.voicepc.demos.web.vo;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.awt.*;

@Configuration
public class RobotVo {
    @Bean
    public Robot robot() {
        try {
            System.setProperty("java.awt.headless", "false");
            // 检查是否在无头环境中运行
            boolean isHeadless = GraphicsEnvironment.isHeadless();
            if (!isHeadless) {
                return new Robot();
            } else {
                System.out.println("警告: 当前在无头环境中运行，无法创建Robot实例");
                return null;
            }
        } catch (AWTException e) {
            System.err.println("创建Robot实例失败: " + e.getMessage());
            return null;
        }
    }
}
